<?php if (isset($_GET['query']) AND count($data['results']['bindings'])): ?>
	<h2>Stores that might have some results for your query:</h2>
<?php $query = urlencode(trim($_GET['query'])) ?>
<ul>
<?php foreach ($data['results']['bindings'] as $result): ?>
	<li>
		<?php $name = str_replace('http://api.talis.com/stores/','', $result['store']['value']) ?>
		<a href="/<?php echo $name  ?>/services/sparql?query=<?php echo $query ?> "><?php echo $name ?></a>
	</li>
	
<?php endforeach ?>
</ul>
<?php endif?>

<form method="get" accept-charset="utf-8">
	<label>Sparql:
		<textarea class="sparql" rows="20" cols="40" name="query"><?php if ( isset($_GET['query']) ): echo stripslashes(htmlentities($_GET['query']));?>
		<?php else:?>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
<?php endif?></textarea>
	</label>
	<div><input type="submit"  value="Query" /></div>
</form>
<?php if (isset($generated_query)): ?>
	<form method="get" accept-charset="utf-8" action="/silkworm-dev/services/sparql">
		<label>Sparql:
			<textarea class="sparql" rows="20" cols="40" name="query"><?php echo htmlentities($generated_query) ?></textarea>
		</label>
		<div><input type="submit"  value="Query" /></div>
	</form>
	
<?php endif ?>
